package com.mswyt.utils.msHandlebean.annotation;

import org.springframework.stereotype.Component;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 比如如下表 A{id,bId,name} ; B{id,cId,name} ; C{id ,dId,name} ;  D{id ,name,code}
 * 如何只查A表带出D表的code？
 * 以往写法：select d.code form A a left join B b on a.bId = b.id left join C c on c.id = b.cId left join D d on d.id = c.Did;
 * 那么现在这个注解存在的意义就是替代这些left join
 *------例子用户表---
 * @MsJoinMoreTables({
 * @MsJoinTable(joinTable = "ms_room", moreJoinCondition = "room_id@id",needFields = "type@roomType"),
 * @MsJoinTable(joinTable = "ms_floor", moreJoinCondition = "floor_id@id", needFields = {"name@floorName","id@floorId"}),
 * @MsJoinTable(joinTable = "ms_building", moreJoinCondition = "building_id@id", needFields = {"name@buildName","remark@buildRemark","id@buildId"})
 * })
 * @TableField(value = "room_id")
 * private String roomId;
 * -----
 * @author: mashuai
 * @ClassName: MsJoinTable
 */
@Component
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MsJoinMoreTables {
    //查询条件，必须使用具体表名.字段名
    String condition() default "";

    //配置moreJoinCondition属性
    MsJoinTable[] value();
}
